package com.example.producer.controller;

import com.example.producer.pojo.Person;
import com.example.producer.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 86188
 */
@RestController
public class PersonController {

    @Autowired
    private PersonService personService;

    @RequestMapping(value = "/save",method = RequestMethod.POST)
    public List<Person> save(@RequestBody String name) {
        return personService.findAll(name);
    }

    @RequestMapping(value = "/list")
    public List<Person> list() {
        return personService.list();
    }

    @RequestMapping("/hello")
    public String hello(@RequestParam String name) {
        return "hello "+name+"，producer is ready";
    }
}
